<%@page import="org.quickbundle.orgauth.cache.RmPartyTypeCache"%>
<%@page import="org.quickbundle.orgauth.IOrgauthConstants"%>
<%@page import="com.dfhc.rm.user.IUserConstants"%>
<%@page import="org.quickbundle.orgauth.rmuser.util.IRmUserConstants"%>
<%@page import="com.dfhc.util.CryptoHelper"%>
<%@ page contentType="text/html; charset=UTF-8" language="java"%>
<!--_meta 作为公共模版分离出去-->
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link rel="Bookmark" href="/favicon.ico" >
<link rel="Shortcut Icon" href="/favicon.ico" />

<!-- 全局js 和css包 -->
<%@ include file="/jsp/include/web/new/global.jsp" %>
<title>用户管理</title>
<!--/meta 作为公共模版分离出去-->

<link rel="stylesheet" href="<%=request.getContextPath() %>/css/ztree/demo.css" type="text/css">
<link rel="stylesheet" href="<%=request.getContextPath() %>/css/ztree/zTreeStyle/zTreeStyle.css" type="text/css">
<%-- <script type="text/javascript" src="<%=request.getContextPath() %>/js/ztree/jquery-1.4.4.min.js"></script> --%>
<%-- <script type="text/javascript" src="${pageContext.request.contextPath }/js/new/js/jquery.min.js"></script>   --%>
<script type="text/javascript" src="<%=request.getContextPath() %>/js/ztree/jquery.ztree.core-3.5.js"></script>
<script type="text/javascript" src="<%=request.getContextPath() %>/js/ztree/jquery.ztree.excheck-3.5.js"></script>

<script type="text/javascript" src="${pageContext.request.contextPath }/js/h-ui.admin/jquery.validation/1.14.0/jquery.validate.js"></script> 
<script type="text/javascript" src="${pageContext.request.contextPath }/js/h-ui.admin/jquery.validation/1.14.0/validate-methods.js"></script> 
<script type="text/javascript" src="${pageContext.request.contextPath }/js/h-ui.admin/jquery.validation/1.14.0/messages_zh.js"></script> 

<title>添加用户 </title>

<%@ taglib uri="/dfhc" prefix="dfhc" %>
</head>
<script type="text/javascript">

var names = "";
var ids = "";
var setting = {
	view: {
		dblClickExpand: false,
		showLine: false,
		selectedMulti: false
	},
	data: {
		simpleData: {
			enable:true,
			idKey: "id",
			pIdKey: "pId",
			rootPId: ""
		}
	},
	callback: {
		beforeClick: function(treeId, treeNode) {
			var zTree = $.fn.zTree.getZTreeObj("tree");
			if (treeNode.isParent) {
				zTree.expandNode(treeNode);
				return false;
			} else {
				demoIframe.attr("src",treeNode.file + ".html");
				return true;
			}
		},
		onCheck:onCheck  
	},
	check: {
		enable: true,
		chkStyle: "checkbox",
		chkboxType: { "Y" : "ps", "N" : "ps" }
	} 
};

 function onCheck(e,treeId,treeNode){  
            var treeObj=$.fn.zTree.getZTreeObj("treeDemo"),  
            nodes=treeObj.getCheckedNodes(true),  
            v="";
            s="";  
            for(var i=0;i<nodes.length;i++){ 
            v+=nodes[i].name + ","; 
            s+=nodes[i].id + ","; 
            
            //console.log("节点id:"+nodes[i].id+"节点名称"+v); //获取选中节点的值  
            } 
            names = v.substring(0,v.length-1);
            ids = s.substring(0,s.length-1);
 }

var msg;
function ajaxEx(id){
	$.ajax({
	   type: "POST",
	   url: getRootPath()+'<%=CryptoHelper.encryptUrl(request,"/pubController/getAuthorityTree")%>', 
	   async: false,
	   data: {'id': id},
	   success: function(msg){
	   var t = $("#treeDemo");
		t = $.fn.zTree.init(t, setting, eval(msg));
		demoIframe = $("#testIframe");
		var zTree = $.fn.zTree.getZTreeObj("tree");
	   },
	   error: function(msg){
	   }
	});
}
		
var code;
		
function showCode(str) {
	if (!code) code = $("#code");
	code.empty();
	code.append("<li>"+str+"</li>");
}
		
$(document).ready(function(){
	ajaxEx($("#id").val());
});
</script>
<body>
	<div style="z-index: 9999; display: none;" id="organizationContent">
		<div class="zTreeDemoBackground">
			<ul id="treeDemo" class="ztree"></ul>
		</div>
	</div>

	<article class="page-container">

	<form action="" method="post" class="form form-horizontal" id="form-member-add" >
	<div id="content" style="height:250px;width:700px;">
		
		
	</div>
		<input type="hidden" name="view_id" value="<%=IOrgauthConstants.PartyView.DEFAULT.id() %>" id="view_id"></input>
		<input type="hidden" name="isInherit" value="0"></input>
		<input type="hidden" name="party_type_id"  value="<%=IOrgauthConstants.Config.isUserRelationParty.value() && RmPartyTypeCache.getPartyType(IRmUserConstants.TABLE_NAME) != null ? RmPartyTypeCache.getPartyType(IRmUserConstants.TABLE_NAME).getId() : ""%>"/>	
		<input type="hidden" id="id" name="role_id" value="${treeId}">
		<input type="hidden" id="function_node_ids" name="function_node_ids" value="">
		<input type="hidden" id="function_node_id_names" name="function_node_id_names" value="">
		<div id="content" style="height:150px;width:700px;">
		
		
		</div>
		<dfhc:div templateId="h_ui_div_row_cl">
			<dfhc:div templateId="h_ui_div_pop_up_button">
				<dfhc:button templateId="h_ui_submit_button" />
			</dfhc:div>
		</dfhc:div>
	</form>
</article>



<script type="text/javascript">
$(function(){
    	var top = "20px";    	
    	$("#organizationContent").css({
    	left:"10px",
    	top:top,
    	display:"block",
    	width:"400px",
    	position:"absolute"
    	}).slideDown("fast");

	$('.skin-minimal input').iCheck({
		checkboxClass: 'icheckbox-blue',
		radioClass: 'iradio-blue',
		increaseArea: '20%'
	});
	
	$("#form-member-add").validate({
		rules:{
		
		},
 		messages: {
	     
	    },		
		onkeyup:false,
		focusCleanup:true,
		success:"valid",
		submitHandler:function(form){
			var url = getRootPath()+'<%=CryptoHelper.encryptUrl(request,"/pubController/updateRoleFunctionNode")%>'
			$("#function_node_ids").val(ids);
			$("#function_node_id_names").val(names);
			//提交成功关闭
			submitAjax(url,$("#form-member-add").serialize()); 		    		    		
			layer_close();			
		}
	});
});
</script> 
<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>